// Created by carolsail

const {ccclass, property} = cc._decorator;

@ccclass
export default class BaseLayer extends cc.Component {

    show() {
        this.node.active = true;
    }

    hide() {
        this.node.active = false;
    }

    fadeIn(node: cc.Node, scale: number = 1.5, speed: number = 0.3){
        node.setScale(scale);
        node.opacity = 0;
        const callback = cc.callFunc(()=>{}, this);
        const action = cc.sequence(cc.spawn(cc.fadeTo(speed, 255), cc.scaleTo(speed, 1.0)), callback);
        cc.tween(node).then(action).start()
    }

    fadeOut(node: cc.Node, scale: number = 0.5, speed: number = 0.3){
        node.setScale(scale);
        node.opacity = 0;
        const callback = cc.callFunc(()=>{}, this);
        const action = cc.sequence(cc.spawn(cc.fadeTo(speed, 255), cc.scaleTo(speed, 1.0)), callback);
        cc.tween(node).then(action).start()
    }

    zoomIn(node: cc.Node, scale: number = 1.5, speed: number = 0.3){
        node.setScale(scale)
        const act = cc.scaleTo(speed, 1)
        cc.tween(node).then(act).start()
    }

    zoomOut(node: cc.Node, scale: number = 0.5, speed: number = 0.3){
        node.setScale(scale)
        const act = cc.scaleTo(speed, 1)
        cc.tween(node).then(act).start()
    }
}
